//
//  CircleViewController.m
//  EducationOID
//
//  Created by slz on 2017/6/19.
//  Copyright © 2017年 bnsr. All rights reserved.
//

#import "CircleViewController.h"
#import "CircleCollectionViewCell.h"

//@interface CircleView : UIView
//@property (nonatomic, strong) CAShapeLayer *progressLayer;
//@end
//
//@implementation CircleView
//
//-(instancetype)initWithFrame:(CGRect)frame{
//    self = [super initWithFrame:frame];
//    if (self){
//        CAShapeLayer *trackLayer = [CAShapeLayer layer];
//        trackLayer.frame = self.bounds;
//        //清空填充色
//        trackLayer.fillColor = [UIColor clearColor].CGColor;
//        //设置画笔颜色 即圆环背景色
//        trackLayer.strokeColor =  [UIColor colorWithRed:170/255.0 green:210/255.0 blue:254/255.0 alpha:1].CGColor;
//        trackLayer.lineWidth = 7;
//        //设置画笔路径
//        UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(self.frame.size.width/2.0, self.frame.size.height/2.0) radius:self.frame.size.width/2.0 - 10 startAngle: M_PI_2 + M_PI_2/3 endAngle:M_PI/3 clockwise:YES];
//        //path 决定layer将被渲染成何种形状
//        trackLayer.path = path.CGPath;
//        [self.layer addSublayer:trackLayer];
//        
//        CALayer * pointLayer = [CALayer new];
//        pointLayer.size = CGSizeMake(10, 10);
//        pointLayer.center = CGPointMake(frame.size.width/2,frame.size.height/2);
//        pointLayer.cornerRadius = 5;
//        pointLayer.backgroundColor = [UIColor colorWithRed:170/255.0 green:210/255.0 blue:254/255.0 alpha:1].CGColor;
//        [self.layer addSublayer:pointLayer];
//        
//        CAGradientLayer * gradientLayer = [CAGradientLayer new];
//        gradientLayer.frame = self.bounds;
//        gradientLayer.colors = @[(__bridge id)[UIColor orangeColor].CGColor, (__bridge id)[UIColor yellowColor].CGColor];
//        gradientLayer.startPoint = CGPointMake(0.2, 0);
//        gradientLayer.endPoint = CGPointMake(0.8, 1);
//        gradientLayer.mask = trackLayer;
//        
//        
//        
//    }
//    return self;
//}
//
//- (CGPoint)centerPoint{
//    return CGPointMake(self.frame.size.width/2.0, self.frame.size.height/2.0);
//}
//
//-(CGPoint) calcCircleCoordinateWithCenter:(CGPoint) center  andWithAngle : (CGFloat) angle andWithRadius: (CGFloat) radius{
//    CGFloat x2 = radius*cosf(angle*M_PI/180);
//    CGFloat y2 = radius*sinf(angle*M_PI/180);
//    return CGPointMake(center.x+x2, center.y-y2);
//}
//
//- (CGFloat)numberToTargetPoint:(CGFloat)number{
//    
//    return 0;
//}
//
//- (void)addLineWithDataArray:(NSArray *)arr{
//    CGFloat perAngle = (M_PI * 2 - M_PI/3)/280;
//    for (int i = 0; i <= arr.count; i++){
//        CGFloat startAngel = (-(M_PI + M_PI/3) + (perAngle * i *40));
//        CGFloat endAngel = startAngel + perAngle;
//        
//        
//        
//        UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:[self centerPoint] radius:self.frame.size.width/2.0 - 17 startAngle:startAngel endAngle:endAngel clockwise:YES];
//        
//        // 将path绘制出来
//        
//        CAShapeLayer *lineLayer = [CAShapeLayer layer];
//        
//        lineLayer.lineWidth = 20;
//        lineLayer.strokeColor = [UIColor colorWithRed:170/255.0 green:210/255.0 blue:254/255.0 alpha:1].CGColor;
//        lineLayer.path = path.CGPath;
//        lineLayer.fillColor = nil; // 默认为blackColor
//        [self.layer addSublayer:lineLayer];
//    }
//}



//@end

@interface CircleViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>

@property (nonatomic,strong) UICollectionView *collectionView;

@end

@implementation CircleViewController
{
    NSArray * _dataPoint;
    BOOL _state;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.showNavigationBar = YES;
    self.view.backgroundColor = [UIColor whiteColor];
//    
//    CircleView * circleView = [[CircleView alloc]initWithFrame:CGRectMake(11, 20, kScreenWidth - 22, kScreenWidth - 22)];
//    circleView.backgroundColor = [UIColor lightGrayColor];
//    [self.view addSubview:circleView];
    
//    _dataPoint = @[@110,@120,@108,@150,@130,@150,@120,@170,@123,@144,@155,@173,@129,@183,@155,@145,@166,@133,@145,@166,@142,@153,@164];
//    [circleView addLineWithDataArray:_dataPoint];
//    UICollectionViewFlowLayout * layout = [[UICollectionViewFlowLayout alloc]init];
//    layout.minimumLineSpacing = 0;
//    layout.minimumInteritemSpacing = 0;
//    layout.itemSize = CGSizeMake(60, 400);
//    layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
//    _collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, 400) collectionViewLayout:layout];
//    [_collectionView registerClass:[CircleCollectionViewCell class] forCellWithReuseIdentifier:@"CircleCollectionViewCell"];
//    _collectionView.delegate = self;
//    _collectionView.dataSource = self;
//    
//    
//    [self.view addSubview:_collectionView];
//    
//    _state = NO;
    // Do any additional setup after loading the view.
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake(60, 400);
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString * reuserIndetifier = @"CircleCollectionViewCell";
    CircleCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuserIndetifier forIndexPath:indexPath];
    cell.point1 = [_dataPoint[indexPath.row] floatValue];
    if (indexPath.row < _dataPoint.count - 1)
    cell.point2 = [_dataPoint[indexPath.row + 1] floatValue];
    cell.backgroundColor = [UIColor yellowColor];

    return cell;
}




- (void)lineForTwoPoint:(CGFloat)point1 point2:(CGFloat)point2{
    
}

-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
    return UIEdgeInsetsMake(0, 0, 0, 0);//分别为上、左、下、右
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return _dataPoint.count;
}

-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}

//-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
//
//    _state = !_state;
//    [self setNeedsStatusBarAppearanceUpdate];
//}
//
//
//
//- (UIStatusBarStyle)preferredStatusBarStyle {
//    return _state ? UIStatusBarStyleLightContent : UIStatusBarStyleDefault;
//}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
